<?php 
	include("includes/config.php");
	include("includes/class/empresarial_dependiente.class.php");
    include("includes/class/payRoll.class.php");
    
	
    $nomina = new Payroll();
    
	
	$empresarial_dependiente = new Empresarial_dependiente();
	$code 		= $_POST['code'];
    $inicio     = cambiarFormatoFecha($_POST['ini'],2);
    $fin        = cambiarFormatoFecha($_POST['fin'],2);
    
    $empresa    = $nomina->listCompanySelect($code);
    $empleados  = $nomina->obtenerDatosEmpleados($code,$inicio,$fin);
    $count      = count ($empleados);
        
	echo "<company_name>".$empresa->nombre."</company_name>";
	echo "<company_nit>".$empresa->nit."</company_nit>";
	echo "<company_address>".$empresa->direccion."</company_address>";
	echo "<company_code>".$empresa->codigo."</company_code>";
    echo "<contRow>".$count."</contRow>";
    echo '<empleados>
        <table class="tbl_form" align="center">
            <tr style="background-color:#808080">
                            
                        	<td style="color:#FFFBF0" colspan="4">BASE Y S SOCIAL</td>
							<td style="color:#FFFBF0" colspan="4">INGRESOS TRABAJADOR</td>
                            <td style="color:#FFFBF0" colspan="1">TOTAL</td>
                            <td style="color:#FFFBF0" colspan="5">DESCUENTOS TRABAJADOR</td>
                            <td style="color:#FFFBF0" colspan="1">A PAGAR</td>
                        </tr>
                        <tr style="border: black; color:#FFFBF0; background-color:#808080" >
                            <td align="left" >NOMBRES Y APELLIDOS</td>
                            <td>IDENTIFICA USU</td>
                            <td align="right">SALARIO BASE</td>
                            <td align="left">DIAS</td>
                            <td align="left">VALOR 1</td>
                            <td align="left">DER</td>
                            <td align="left">AUXILIO</td>
                            <td align="left">CON</td>
                            <td align="left">TOTAL</td>
                            <td align="left">DESCUENTOS</td>
                            <td align="left">AH</td>
                            <td align="left">AP</td>
                            <td align="left">SALUD TRA</td>
                            <td align="left">PENSION</td>
                            <td align="left">NETO PAGAR</td>
                        </tr>';
    for ($i=0;$i<$count;$i++)
    {
    echo '
    
        <tr>
            <td align="left" ><input style="width:110px" type="text" readonly="true" name="nombre'.$i.'"
                id="nombre'.$i.'" value="'.$empleados[$i]->nombre.' '.$empleados[$i]->apellido.'"></td>
            
            <td align="left" ><input style="width:80px" type="text" readonly="true" name="cedula'.$i.'"
                id="cedula'.$i.'" value="'.$empleados[$i]->cedula.'"></td>
            
            <td align="right"><input style="width:50px" type="text" readonly="true" name="basico'.$i.'"
                id="basico'.$i.'" value="'.$empleados[$i]->basico.'"></td>
            
            <td align="left"><input style="width:15px" type="text" name="dias'.$i.'" 
                id="dias'.$i.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
            
            <td align="left"><input style="width:50px "type="text" readonly="true" name="valor1_'.$i.'" 
                id="valor1_'.$i.'"></td>
            
            <td align="left"><input style="width:50px" type="text" name="der'.$i.'" 
                id="der'.$i.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
                
            <td align="left"><input style="width:50px" type="text" name="aux'.$i.'" 
                id="aux'.$i.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
                
            <td align="left"><input style="width:50px" type="text" name="con'.$i.'" 
                id="con'.$i.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
                
            <td align="left"><input style="width:50px" type="text" readonly="true" name="total'.$i.'" 
                id="total'.$i.'"></td>
                
            <td align="left"><input style="width:50px" type="text" name="descu'.$i.'" 
                id="descu'.$i.'" value="'.$empleados[$i]->descuento.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
                
            <td align="left"><input style="width:50px" type="text" name="AH'.$i.'" 
                id="AH'.$i.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
                
            <td align="left"><input style="width:50px" type="text" name="AP'.$i.'" 
                id="AP'.$i.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
                
            <td align="left"><input style="width:50px" type="text" name="salud'.$i.'" 
                id="salud'.$i.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
            
            <td align="left"><input style="width:50px" type="text" name="pension'.$i.'" 
                id="pension'.$i.'" onkeypress = "return onlyNumbers(event)" onkeyup="javascript:calcularTotal('.$i.')"></td>
                
            <td align="left"><input style="width:50px" type="text" readonly="true"name="neto'.$i.'" id="neto'.$i.'"></td>
            
        </tr>';
    }
    
    echo '
            <tr style="border: black; color:#FFFBF0; background-color:#808080">
                <td colspan="2">
                    TOTALES:
                </td>
                <td align="right"><input style="width:50px" type="text" readonly="true" name="Tbasico"
                id="Tbasico"</td>
                
                <td align="left"><input style="width:15px" type="text" name="Tdias" readonly="true"
                    id="Tdias"></td>
                
                <td align="left"><input style="width:50px "type="text" readonly="true" name="Tvalor1_" 
                    id="Tvalor1_"></td>
                
                <td align="left"><input style="width:50px" type="text" name="Tder" readonly="true"
                    id="Tder"></td>
                    
                <td align="left"><input style="width:50px" type="text" name="Taux" readonly="true"
                    id="Taux"></td>
                    
                <td align="left"><input style="width:50px" type="text" name="Tcon" readonly="true"
                    id="Tcon"></td>
                    
                <td align="left"><input style="width:50px" type="text" readonly="true" name="Ttotal" 
                    id="Ttotal"></td>
                    
                <td align="left"><input style="width:50px" type="text" name="Tdescu" readonly="true"
                    id="Tdescu"</td>
                    
                <td align="left"><input style="width:50px" type="text" name="TAH" readonly="true"
                    id="TAH"></td>
                    
                <td align="left"><input style="width:50px" type="text" name="TAP" readonly="true"
                    id="TAP"></td>
                    
                <td align="left"><input style="width:50px" type="text" name="Tsalud" readonly="true"
                    id="Tsalud"></td>
                
                <td align="left"><input style="width:50px" type="text" name="Tpension" readonly="true"
                    id="Tpension"></td>
                    
                <td align="left"><input style="width:50px" type="text" readonly="true"name="Tneto" id="Tneto"></td>
            </tr>
            </table>
            <table>
                <tr style="border: black; color:#FFFBF0; background-color:#808080">
                    <td>
                        EPS
                    </td>
                    <td>
                        ARL
                    </td>
                    <td>
                        PENSION
                    </td>
                    <td>
                        PARAFISCALES
                    </td>
                    <td>&nbsp;</td>
                    <td>TOTALES</td>
                </tr>';
        for ($i=0;$i<$count;$i++)
            {
            echo '
            
                <tr>
                    <td>
                        <input style="width:50px" type="text" name="Eeps'.$i.'" readonly="true"
                    id="Eeps'.$i.'">
                    </td>
                    <td>
                        <input style="width:50px" type="text" name="Earl'.$i.'" readonly="true"
                    id="Earl'.$i.'">
                    </td>
                    <td>
                        <input style="width:50px" type="text" name="Epension'.$i.'" readonly="true"
                    id="Epension'.$i.'">
                    </td>
                    <td>
                        <input style="width:50px" type="text" name="Eparafiscales'.$i.'" readonly="true"
                    id="Eparafiscales'.$i.'">
                    </td>
                    <td>&nbsp;</td>
                    <td>
                        <input style="width:50px" type="text" name="Etotal'.$i.'" readonly="true"
                    id="Etotal'.$i.'">
                    </td>
                </tr>';
            }
    
    echo '      <tr style="border: black; color:#FFFBF0; background-color:#808080">
                    <td>
                        <input style="width:50px" type="text" name="TEeps" readonly="true"
                    id="TEeps">
                    </td>
                    <td>
                        <input style="width:50px" type="text" name="TEarl" readonly="true"
                    id="TEarl">
                    </td>
                    <td>
                        <input style="width:50px" type="text" name="TEpension" readonly="true"
                    id="TEpension">
                    </td>
                    <td>
                        <input style="width:50px" type="text" name="TEparafiscales" readonly="true"
                    id="TEparafiscales">
                    </td>
                    <td>&nbsp;</td>
                    <td>
                        <input style="width:50px" type="text" name="TEtotal" readonly="true"
                    id="TEtotal">
                    </td>
                </tr>
                
            </table>
            <table>
                <tr style="border: black; color:#FFFBF0; background-color:#808080">
                    <td>PRESTACIONES</td>
                    <td>&nbsp;</td>
                    <td><input style="width:50px" type="text" name="Epara"
                    id="Epara"></td>
                    <td><input style="width:50px" type="text" name="TEpara" readonly="true"
                    id="TEpara"></td>
                </tr>
                 <tr style="border: black; color:#FFFBF0; background-color:#808080">
                    <td>ADMON</td>
                    <td>&nbsp;</td>
                    <td><input style="width:50px" type="text" name="Eadmon" readonly="true"
                    id="Eadmon" value="'.$empresa->admin.'"></td>
                    <td><input style="width:50px" type="text" name="TEadmon" readonly="true"
                    id="TEadmon" value="'.$empresa->admin.'"></td>
                </tr>
                
            </table>
            
            </empleados>';
        
?>